<template>
	<view>
		<cu-custom bgColor="bg-gradual-green" :isBack="true"><block slot="backText">返回</block>
			<block slot="content">会员调查问卷</block>
		</cu-custom>
		<view class="hui">
			您好! 感谢您抽时间填写该健康问卷，我们会根据您的宝贵意见不断改进的，谢谢！
		</view>
		
		<view class="wenti">
			{{item1.name}}
		</view>
		<checkbox-group @change="RadioChange1" data-num="0" style="height: 320upx;background: #fff;border-bottom: 1upx solid #ddd;padding: 0 20upx;">
		 <label class="margin-left" style="display: inline-block;" v-for="item in item1.radio_group" :key="item.value">
			<checkbox class="blue radio" :value="item.value"></checkbox>
			<text class="margin-left">{{item.value}}</text>
		 </label>
		</checkbox-group>
		
		<view class="wenti">
			{{item2.name}}
		</view>
		<checkbox-group @change="RadioChange2" data-num="2" style="height: 250upx;background: #fff;border-bottom: 1upx solid #ddd;padding: 0 20upx;">
		 <label class="margin-left" style="display: inline-block;" v-for="item in item2.radio_group" :key="item.value">
			<checkbox class="blue radio" :value="item.value"></checkbox>
			<text class="margin-left">{{item.value}}</text>
		 </label>
		 <view style="width: 100%;height: 60upx;line-height: 60upx;background-color: #fff;">
		 	<input type="text" v-model="item2.value1" placeholder="请输入其他运动经历" style="margin: 10upx 30upx 0;" />
		 </view>
		</checkbox-group>
		
		<view class="wenti">
			{{item3.name}}
		</view>
		<checkbox-group @change="RadioChange3" data-num="3" style="height: 250upx;background: #fff;border-bottom: 1upx solid #ddd;padding: 0 20upx;">
		 <label class="margin-left" style="display: inline-block;" v-for="item in item3.radio_group" :key="item.value">
			<checkbox class="blue radio" :value="item.value"></checkbox>
			<text class="margin-left">{{item.value}}</text>
		 </label>
		</checkbox-group>
		
		<view class="wenti">
			{{item4.name}}
		</view>
		<checkbox-group @change="RadioChange4" data-num="4" style="height: 250upx;background: #fff;border-bottom: 1upx solid #ddd;padding: 0 20upx;">
		 <label class="margin-left" style="display: inline-block;" v-for="item in item4.radio_group" :key="item.value">
			<checkbox class="blue radio" :value="item.value"></checkbox>
			<text class="margin-left">{{item.value}}</text>
		 </label>
		</checkbox-group>
		
		<view class="wenti">
			{{item5.name}}
		</view>
		<radio-group @change="RadioChange5" style="width: 100%;height: 120upx;background: #fff;">
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="是"></radio>
				<text class="margin-left">是</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="否"></radio>
				<text class="margin-left">否</text>
			</label>
		</radio-group>
		
		<view class="wenti">
			{{item6.name}}
		</view>
		<radio-group @change="RadioChange6" style="width: 100%;height: 120upx;background: #fff;">
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="是"></radio>
				<text class="margin-left">是</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="否"></radio>
				<text class="margin-left">否</text>
			</label>
		</radio-group>
		<view class="cu-form-group" style="color: #777;">
			<input style="width: 350upx;padding-left: 20upx;" v-model="item6.value1" placeholder="如果是，请详细说明"></input>
		</view>
		
		<view class="wenti">
			{{item7.name}}
		</view>
		<radio-group @change="RadioChange7" style="width: 100%;height: 240upx;background: #fff;">
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="清晨"></radio>
				<text class="margin-left">清晨</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="上午"></radio>
				<text class="margin-left">上午</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="下午"></radio>
				<text class="margin-left">下午</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="晚上"></radio>
				<text class="margin-left">晚上</text>
			</label>
		</radio-group>
		
		<view class="wenti">
			{{item8.name}}
		</view>
		<radio-group @change="RadioChange8" style="width: 100%;height: 240upx;background: #fff;">
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="轻松"></radio>
				<text class="margin-left">轻松</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="比较轻松"></radio>
				<text class="margin-left">比较轻松</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="有点费力"></radio>
				<text class="margin-left">有点费力</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="非常费力"></radio>
				<text class="margin-left">非常费力</text>
			</label>
		</radio-group>
		
		<view class="wenti">
			{{item9.name}}
		</view>
		<radio-group @change="RadioChange9" style="width: 100%;height: 240upx;background: #fff;">
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="2次"></radio>
				<text class="margin-left">2次</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="3次"></radio>
				<text class="margin-left">3次</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="4次"></radio>
				<text class="margin-left">4次</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="5次"></radio>
				<text class="margin-left">5次</text>
			</label>
		</radio-group>
		
		<view class="wenti">
			{{item10.name}}
		</view>
		<radio-group @change="RadioChange10" style="width: 100%;height: 240upx;background: #fff;">
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="1个月"></radio>
				<text class="margin-left">1个月</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="3个月"></radio>
				<text class="margin-left">3个月</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="6个月"></radio>
				<text class="margin-left">6个月</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="1年"></radio>
				<text class="margin-left">1年</text>
			</label>
		</radio-group>
		
		<view class="wenti">
			{{item11.name}}
		</view>
		<radio-group @change="RadioChange11" style="width: 100%;height: 120upx;background: #fff;">
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="是"></radio>
				<text class="margin-left">是</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="否"></radio>
				<text class="margin-left">否</text>
			</label>
		</radio-group>
		
		<view class="wenti">
			{{item12.name}}
		</view>
		<radio-group @change="RadioChange12" style="width: 100%;height: 120upx;background: #fff;">
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="是"></radio>
				<text class="margin-left">是</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="否"></radio>
				<text class="margin-left">否</text>
			</label>
		</radio-group>
		
		<view class="wenti">
			{{item13.name}}
		</view>
		<radio-group @change="RadioChange13" style="width: 100%;height: 320upx;background: #fff;">
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="是"></radio>
				<text class="margin-left">是</text>
			</label>
			<label class="margin-left" style="width: 100%;height: 60upx;display: block;">
				<radio class="blue radio" value="否"></radio>
				<text class="margin-left">否</text>
			</label>
		</radio-group>
		
		
		<view class="bg-gradual-green" style="position: fixed;bottom: 0;left: 0;width: 100%;text-align: center;height: 100upx;line-height: 100upx;z-index: 333;" @click="submit()">
			下一步
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				item1: {
					name: '1. 您平时的生活及饮食习惯？（多选）',
					radio_group: [
						{
							value: '久坐少动',
							checked: false
						},
						{
							value: '抽烟',
							checked: false
						},
						{
							value: '酗酒',
							checked: false
						},
						{
							value: '暴饮暴食',
							checked: false
						},
						{
							value: '不吃早餐',
							checked: false
						},
						{
							value: '经常性宵夜',
							checked: false
						},
						{
							value: '膳食重油重盐',
							checked: false
						},
						{
							value: '经常性熬夜',
							checked: false
						},
						{
							value: '加班较多',
							checked: false
						},
						{
							value: '三餐不规律',
							checked: false
						},
						{
							value: '不吃水果',
							checked: false
						},
						{
							value: '吃荤偏多',
							checked: false
						},
						{
							value: '垃圾食品摄入频繁过多',
							checked: false
						},
					]
				},
				item2: {
					name: '2.您以前有的运动经历是？（多选）',
					value1:'',
					radio_group: [
						{
							value: '跑步',
							checked: false
						},
						{
							value: '散步',
							checked: false
						},
						{
							value: '游泳',
							checked: false
						},
						{
							value: '力量训练',
							checked: false
						},
						{
							value: '广场舞',
							checked: false
						},
						{
							value: '健身房健身',
							checked: false
						},
						{
							value: '篮球',
							checked: false
						},
						{
							value: '其他',
							checked: false
						},
					]
				},
				item3: {
					name: '3. 您现在对哪些健身运动项目感兴趣？（多选）',
					radio_group: [
						{
							value: '跑步机有氧',
							checked: false
						},
						{
							value: '力量训练',
							checked: false
						},
						{
							value: '球类运动',
							checked: false
						},
						{
							value: '椭圆机行走',
							checked: false
						},
						{
							value: '游泳',
							checked: false
						},
						{
							value: '瑜伽／普拉提',
							checked: false
						},
						{
							value: '舞蹈',
							checked: false
						},
						{
							value: '划船机有氧',
							checked: false
						},
						{
							value: '游泳',
							checked: false
						},
						{
							value: '单车骑行',
							checked: false
						},
						{
							value: '私人订制',
							checked: false
						},
					]
				},
				item4: {
					name: '4. 您运动健身的需求是什么？（多选）',
					radio_group: [
						{
							value: '提高心肺耐力',
							checked: false
						},
						{
							value: '减重/减脂',
							checked: false
						},
						{
							value: '改善体态',
							checked: false
						},
						{
							value: '改善睡眠',
							checked: false
						},
						{
							value: '释放压力',
							checked: false
						},
						{
							value: '增强体能',
							checked: false
						},
						{
							value: '增加肌肉',
							checked: false
						},
					]
				},
				item5: {
					name: '5. 您平常坚持每周两次以上运动吗？',
					value: ''
				},
				item6: {
					name: '6. 您在之前运动中或生活中有受伤的经历吗？',
					value: '',
					value1: ''
				},
				item7: {
					name: '7. 您现在健身时间安排在什么时间段？',
					value: ''
				},
				item8: {
					name: '8. 您健身接受的运动强度？',
					value: ''
				},
				item9: {
					name: '9. 您每周准备在我们这里健身几次？',
					value: ''
				},
				item10: {
					name: '10. 您准备坚持规律运动健身多久？',
					value: ''
				},
				item11: {
					name: '11. 您健身的过程中，有家人、朋友、爱人支持吗？',
					value: ''
				},
				item12: {
					name: '12. 当您健身遇到困难、阻碍或挫折时，您能保持坚韧的毅力吗？',
					value: ''
				},
				item13: {
					name: '13. 您现在的工作是否维持同一姿势做重复性动作?',
					value: ''
				},
				openid:'',
				userId: '', // 用户id
			};
		},
		onLoad:function(e){
			if ( e.userId ) {
				this.userId = e.userId
			}
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.reLaunch({
						url: 'pagesA/login/login'
					})
				}
			});
		},
		methods:{
			RadioChange1(e) {
				var items = this.item1.radio_group,
						values = e.detail.value;
				for (var i = 0, lenI = items.length; i < lenI; ++i) {
						const item = items[i]
						if(values.includes(item.value)){
								this.$set(item,'checked',true)
						}else{
								this.$set(item,'checked',false)
						}
				}
			},
			RadioChange2(e) {
				var items = this.item2.radio_group,
						values = e.detail.value;
				for (var i = 0, lenI = items.length; i < lenI; ++i) {
						const item = items[i]
						if(values.includes(item.value)){
								this.$set(item,'checked',true)
						}else{
								this.$set(item,'checked',false)
						}
				}
			},
			RadioChange3(e) {
				var items = this.item3.radio_group,
						values = e.detail.value;
				for (var i = 0, lenI = items.length; i < lenI; ++i) {
						const item = items[i]
						if(values.includes(item.value)){
								this.$set(item,'checked',true)
						}else{
								this.$set(item,'checked',false)
						}
				}
			},
			RadioChange4(e) {
				var items = this.item4.radio_group,
						values = e.detail.value;
				for (var i = 0, lenI = items.length; i < lenI; ++i) {
						const item = items[i]
						if(values.includes(item.value)){
								this.$set(item,'checked',true)
						}else{
								this.$set(item,'checked',false)
						}
				}
			},
			RadioChange5(e) {
				this.item5.value = e.detail.value
			},
			RadioChange6(e) {
				console.log(e.detail.value)
				if (e.detail.value == '是') {
					this.show1 = true
				} else {
					this.show1 = false
				}
				console.log(this.show1)
				this.item6.value = e.detail.value
			},
			RadioChange7(e) {
				this.item7.value = e.detail.value
			},
			RadioChange8(e) {
				this.item8.value = e.detail.value
			},
			RadioChange9(e) {
				this.item9.value = e.detail.value
			},
			RadioChange10(e) {
				this.item10.value = e.detail.value
			},
			RadioChange11(e) {
				this.item11.value = e.detail.value
			},
			RadioChange12(e) {
				this.item12.value = e.detail.value
			},
			RadioChange13(e) {
				this.item13.value = e.detail.value
			},
			submit () {
				var o = this
				// if (	this.item1.value1 == '' || 
				// 			this.item1.value2 == '' ||
				// 			this.item2.value == '' || 
				// 			this.item5.value == '' || 
				// 			this.item6.value == '' || 
				// 			this.item7.value == '') {
				// 	uni.showToast({
				// 		title: '您有未完善的选项',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				// let g1 = this.item3.radio_group
				// let group1 = g1.filter((item) => {
				//   return item.checked == true;
				// });
				
				// let g2 = this.item4.radio_group
				// let group2 = g1.filter((item) => {
				//   return item.checked == true;
				// });
				
				// let g3 = this.item8.radio_group
				// let group3 = g1.filter((item) => {
				//   return item.checked == true;
				// });
				// 3.4.8号复选框不能为空
				// if (group1.length == 0 || group2.length == 0 || group3.length == 0) {
				// 	uni.showToast({
				// 		title: '您有未完善的选项',
				// 		icon: 'none'
				// 	})
				// 	return
				// }
				// 执行完上面的为空验证之后提交事件
				var describe = []
				describe[0] = this.item1
				describe[1] = this.item2
				describe[2] = this.item3
				describe[3] = this.item4
				describe[4] = this.item5
				describe[5] = this.item6
				describe[6] = this.item7
				describe[7] = this.item8
				describe[8] = this.item9
				describe[9] = this.item10
				describe[10] = this.item11
				describe[11] = this.item12
				describe[12] = this.item13
				console.log(describe)
				// 缓存数据到下一页 再一起提交
				uni.setStorage({
					key: 'describe',
					data: describe
				})
				setTimeout(function() {
					uni.navigateTo({
						url:'./next_add?membersId=' + o.userId
					})
				}, 300);
			},
			setAjax(){
				uni.hideLoading()
			},
			jump(e){
				uni.navigateTo({
					url: e.currentTarget.dataset.src
				});
			},
		}
	}
</script>

<style>
	.block {
		border-bottom: 1upx solid #ccc;
	}
	.cu-form-group+.cu-form-group {
    border-top: none;
	}
	.radio {
		transform:scale(0.8);
	}
	.zt{
		font-size: 40upx;
		margin-left: 20upx;
	}
	.cu-form-group .title {
		min-width: calc(4em + 15px);
	}
	.hui{
		margin: 30upx;
	}
	.wenti{
		background: #ffffff;
		padding: 30upx;
		font-size: 30upx;
	}
</style>
